<template>
	<view class="container">
		<block v-if="list.length">
			<act-list :range="list"></act-list>
		</block>
		<block v-else>
			<no-data></no-data>
		</block>
		<no-more v-if="index_page >= total_page"></no-more>
	</view>
</template>

<script>
import noData from '@/components/no-data'
import actList from '@/components/act-list'
import consultList from '@/components/consult-list'
import { userFollowList } from '@/utils/http'
export default {
	data() {
		return {
			index_page: 0,
			total_page: 1,
			list: []
		}
	},
	components: {
		actList,
		consultList,
		noData
	},
	computed: {
		user_info() {
			return this.store.state.user_info
		}
	},
	methods: {
		getUserFollow() {
			if (!this.user_info) return
			userFollowList({
				user_id: this.user_info.id,
				type: 'activity',
				page: this.index_page + 1
			}).then(res => {
				if (res) {
					this.index_page = res.current_page
					this.total_page = res.last_page
					this.list = [...this.list, ...res.data]
					this.$forceUpdate()
					console.log('this.list',this.list)
				}
			})
		}
	},
	//上拉加载
	onReachBottom() {
		if (this.index_page < this.total_page) {
			this.getUserFollow()
		}
	},
	onLoad() {
		this.getUserFollow()
	}
}
</script>

<style>
</style>